package com.example.personnel_oa.controller;


import com.example.comment_oa.pojos.Talentpool;
import com.example.comment_oa.pojos_vo.Talentpool_vo;
import com.example.comment_oa.response.AjaxResponse;
import com.example.comment_oa.util.EaxyUtils;
import com.example.personnel_oa.service.TalentpoolService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;


import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;


@RestController
@CrossOrigin
@RequestMapping("personnelOa")
public class TalentpoolController {
    @Autowired
    TalentpoolService talentpoolService;



//    @InitBinder
//    public void initBinder(WebDataBinder binder) {
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        sdf.setLenient(false);
//        binder.registerCustomEditor(Date.class, new CustomDateEditor(sdf, true));
//    }
    //查询出所有人才
    @GetMapping("talentpool/rencai")
    public AjaxResponse selecttalentpool(){
        System.err.println(talentpoolService.Talentpool());
        return AjaxResponse.success(talentpoolService.Talentpool());
    }
    //新增人才
    @PostMapping("talentpool/insertTalentpool")
    public AjaxResponse insertTalentpool(@RequestBody Talentpool talentpool){
        int b = talentpoolService.insertTalentpool(talentpool);
        return AjaxResponse.success(b);
    }
    //新增简历
    @PostMapping("talentpool/insertResume")
    public AjaxResponse insertResume(@RequestBody Talentpool talentpool){
        int b = talentpoolService.insertResume(talentpool);
        return AjaxResponse.success(b);
    }
    @PutMapping("talentpool/deleteTalentpool/{id}")
    public AjaxResponse deleteTalentpool(@PathVariable("id") int id){
        int b = talentpoolService.deleteTalentpool(id);
        return AjaxResponse.success(b);
    }
    @DeleteMapping("talentpool/deleteTalentpools/{id}")
    public AjaxResponse deleteTalentpools(@PathVariable("id") int id){
        int b = talentpoolService.deleteTalentpools(id);
        return AjaxResponse.success(b);
    }
    @PostMapping ("talentpool/selectTalentpool")
    public AjaxResponse selecttalentpool2(@RequestBody Talentpool talentpool){
        List<Talentpool> talentpools = talentpoolService.selectTalentpool(talentpool);
        return AjaxResponse.success(talentpools);
    }
    @PostMapping("talentpool/selectjianli")
    public AjaxResponse selectjianli(){
        List<Talentpool> selectjianli = talentpoolService.selectjianli();
        return AjaxResponse.success(selectjianli);
    }
    @PutMapping("talentpool/update/{talentsTalenttag}/{id}")
    public AjaxResponse update(@PathVariable("talentsTalenttag")String talentsTalenttag,@PathVariable("id") int id){
        int update = talentpoolService.update(talentsTalenttag,id);
        return AjaxResponse.success(update);
    }
    @PutMapping("talentpool/update2/{id}")
    public AjaxResponse update2(@PathVariable("id") int id){
        int update = talentpoolService.update2(id);
        return AjaxResponse.success(update);
    }
    @PostMapping("talentpool/selectResume")
    public AjaxResponse selectResume(@RequestBody Talentpool_vo talentpoolVo){
        List<Talentpool> talentpools = talentpoolService.selectResume(talentpoolVo);
        return AjaxResponse.success(talentpools);
    }
    @PostMapping("talentpool/resumeid/{talentsId}")
    public AjaxResponse resumeId(@PathVariable("talentsId") int talentsId){
      Talentpool talentpools = talentpoolService.resumeId(talentsId);
        return AjaxResponse.success(talentpools);
    }
    @PostMapping("talentpool/wodeguanzhu/{empId}")
    public AjaxResponse wodeguanzhu(@PathVariable("empId") int empId){
        List<Talentpool> wodeguanzhu = talentpoolService.wodeguanzhu(empId);
        return AjaxResponse.success(wodeguanzhu);
    }
    @PostMapping("talentpool/insertguanzhu/{talentsId}/{empId}")
    public AjaxResponse addguanzhu(@PathVariable("talentsId") int talentsId,@PathVariable("empId") int empId){
        int insertguanzhu = talentpoolService.insertguanzhu(talentsId, empId);
        return AjaxResponse.success(insertguanzhu);
    }
    @DeleteMapping("talentpool/delguanzhu/{talentsId}/{empId}")
    public AjaxResponse delguanzhu(@PathVariable("talentsId") int talentsId,@PathVariable("empId") int empId){
        int insertguanzhu = talentpoolService.delguanzhu(talentsId,empId);
        return AjaxResponse.success(insertguanzhu);
    }
    @PostMapping("talentpool/jiaoyangz/{talentsId}/{empId}")
    public AjaxResponse jiaoyangz(@PathVariable("talentsId") int talentsId,@PathVariable("empId") int empId){
        Talentpool jiaoyangz = talentpoolService.jiaoyangz(talentsId, empId);
        return AjaxResponse.success(jiaoyangz);
    }
    @PostMapping("talentpool/selectguanzhu")
    public AjaxResponse selectguanzhu(@RequestBody Talentpool_vo talentpoolVo){
        List<Talentpool> selectguanzhu = talentpoolService.selectguanzhu(talentpoolVo);
        return AjaxResponse.success(selectguanzhu);
    }
    @PostMapping("talentpool/insertwodegz")
    public AjaxResponse insertwodegz(@RequestBody Talentpool talentpool){
        int insertwodegz = talentpoolService.Insertguanzhu(talentpool);
        return AjaxResponse.success(insertwodegz);
    }
    //offer详情根据id查询人才
    @PostMapping("talentpool/offerTalenpool/{talentsId}")
    public AjaxResponse offerTalenpool(@PathVariable("talentsId") int talentsId){
        Talentpool talentpool = talentpoolService.offerTalentpool(talentsId);
        return AjaxResponse.success(talentpool);
    }

}
